package com.limao.CacheManager;

import com.Hazelcast.Cache;
import com.Hazelcast.CacheFactory;
import com.limao.DBDataClass.CrowdVRHomeClass;
import com.limao.DBProvider.CrowdVRHomeProvider;
import com.limao.cache.BasicModule;

public class CrowdVRHomeCache  extends BasicModule{

	private CrowdVRHomeProvider provider;
	private static CrowdVRHomeCache instance;
	
	private String key="VRHome";

	public static CrowdVRHomeCache getInstance() {
		return instance;
	}

	private Cache<String, CrowdVRHomeClass> crowdVRHomeCache;

	public CrowdVRHomeCache() {
    	super("CrowdVRHomeCache");
    	crowdVRHomeCache = CacheFactory.createCache("sys_crowd_VRHomeCache");
		initProvider();
	}
    
    @Override
	public void initialize() {
        super.initialize();
        instance=this;
    }
	
    public void ClearObjectCache()
    {
   		crowdVRHomeCache.clear();
    } 
  
	
	//&新鲜宝  增加正式订单
	public CrowdVRHomeClass Load_CrowdVR(){
		
		CrowdVRHomeClass obj = crowdVRHomeCache.get(key);
		if(obj==null)
		{
			obj = provider.Load_CrowdVR();;
			if (obj != null)
				crowdVRHomeCache.put(key, obj);
		}
		return obj;

		
	}
	
	

	//**************************************************************************************************/	
	private void initProvider() {
		if (provider == null) {
			try {
				provider = CrowdVRHomeProvider.getInstance();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
	
	


}
